<%@ page import="java.lang.StackTraceElement" %>
<%@ page import="java.lang.Thread" %>
<%@ page import="java.util.Map" %>
<%@ page import="java.util.Enumeration" %>
<%@ page import="java.util.Map.Entry" %>
<h1><%=Thread.activeCount() %>Current Threads</h1><%
    Map<Thread,StackTraceElement[]> tStk = Thread.getAllStackTraces();
    for (Map.Entry<Thread,StackTraceElement[]> anEntry : tStk.entrySet()) {
		%><h4><%
			if (Thread.currentThread() == anEntry.getKey()) {
				%><a name="current"></a>CURRENT THREAD: <%
			}
		%>
		<%=anEntry.getKey().toString()%>: <%=anEntry.getKey().getState()%></h4><%
		for (StackTraceElement st: anEntry.getValue()) {
		%><li><%=st.toString()%></li><%
		}
	}%>
<% Enumeration<String> names = getServletContext().getAttributeNames();
%><h1>Attributes</h1> <h2>...for this Application</h2><%
   while (names.hasMoreElements()) {
	   String aName = names.nextElement();
	   %><li><%=aName %> = <%=getServletContext().getAttribute(aName) %></li><%
   }
	names = request.getSession().getAttributeNames();
%><h2>...for this Session</h2><%
   while (names.hasMoreElements()) {
	   String aName = names.nextElement();
	   %><li><%=aName %> = <%=request.getSession().getAttribute(aName) %></li><%
   }
%>